<template>
	<view class="fitting-item" @click="faultPartItemClick">
		<image mode="aspectFill" class="fitting-item__pic" :src="faultPartItem.base64Img" />
		<view class="fitting-item__info">
			<view class="fitting-item__head">
				<text class="fitting-item__title">{{faultPartItem.PartsNum}}</text>
				<view class="fitting-item__tag" v-if="faultPartItem.WarrantyPeriod">
					<text>{{faultPartItem.WarrantyPeriod}}</text>
				</view>
			</view>
			<text class="fitting-item__content">
				{{faultPartItem.PartsName}}
			</text>
			<view class="fitting-item__footer" v-if="faultPartItem.WarrantyCloseDate">
				<text class="fitting-item__price">{{faultPartItem.WarrantyCloseDate | dateFormat}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import Utils from '@/common/utils';
	export default {
		props: {
			faultPartItem: {
				type: Object,
				default () {
					return {}
				}
			}
		},
		filters:{
			//获取日期
			dateFormat(value) {
				if (value) {
					let date = new Date(value);
					let result = Utils.formatDate(date, 'yyyy/MM/dd');
					return result;
				}
				return '';
			},
		},
		methods: {
			//选择故障件
			faultPartItemClick(e) {
				this.$emit("onFaultPartItemClick", this.faultPartItem);
			}
		},
	}
</script>

<style lang="scss">
	@import '../FittingItem/index.scss'
</style>
